PROJ=main
MCU=attiny2313
PROG=usbtiny
AVRDUDE=avrdude
OBJ=avr-objcopy
CC=avr-gcc

.PHONY : avrdude
avrdude : $(PROJ).hex
	$(AVRDUDE) -c $(PROG) -p $(MCU) -U flash:w:$(PROJ).hex
$(PROJ).hex : $(PROJ).elf
	$(OBJ) -j .text -j .data -O ihex $(PROJ).elf $(PROJ).hex
$(PROJ).elf : $(PROJ).o
	$(CC) -g -mmcu=$(MCU) -o $(PROJ).elf $(PROJ).o
$(PROJ).o : $(PROJ).c
	$(CC) -g -Os -mmcu=$(MCU) -c $(PROJ).c
.PHONY : clean
clean :
	rm $(PROJ).o $(PROJ).elf $(PROJ).hex
